/*
 * Copyright (c) 2018. J4dream created
 */

package com.j4dream.property.javabasic.designpattern.singleton;

// 多线程下创建会有问题，可能同时判断到 isn == null, 就会创建多个对象；
// 适合单线程
public class Singleton {
    private static volatile Singleton ins;
    private Singleton() {}
    public static Singleton getIns() {
        if (ins == null) {
            ins = new Singleton();
        }
        return ins;
    }
}

